﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" MasterPageFile="~/Site.master" Inherits="Team4.users.Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <table>
        <tr>
            <td>
                <fieldset>
                    <legend>Edit/Delete Users</legend>
                    <asp:GridView ID="UserGridView" runat="server" AutoGenerateColumns="False" DataKeyNames="UserName,EmailAddress"
                        DataSourceID="UserObjectDataSource">
                        <Columns>
                            <asp:TemplateField ShowHeader="False">
                                <EditItemTemplate>
                                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True"  CssClass="myButton"
                                        CommandName="Update" Text="Update"></asp:LinkButton>
                                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False"  CssClass="myButton"
                                        CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False"  CssClass="myButton"
                                        CommandName="Edit" Text="Edit"></asp:LinkButton>
                                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False"  CssClass="myButton"
                                        CommandName="Delete" Text="Delete"  OnClientClick='return confirm("Are you sure you want to delete this user?");'></asp:LinkButton>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="UserName" HeaderText="UserName" ReadOnly="True" 
                                SortExpression="UserName" />
                            <asp:BoundField DataField="EmailAddress" HeaderText="EmailAddress" 
                                SortExpression="EmailAddress" />
                            <asp:CheckBoxField DataField="Admin" HeaderText="Admin" 
                                SortExpression="Admin" />
                        </Columns>
                    </asp:GridView>
                    <asp:ObjectDataSource ID="UserObjectDataSource" runat="server"
                        DataObjectTypeName="Team4.BLL+User" DeleteMethod="DeletUser" 
                        InsertMethod="CreateUser" SelectMethod="GetAllUsers" TypeName="Team4.BLL+User" 
                        UpdateMethod="UpdateUser">
                        <InsertParameters>
                            <asp:Parameter Name="userName" Type="String" />
                            <asp:Parameter Name="email" Type="String" />
                            <asp:Parameter Name="admin" Type="Boolean" />
                            <asp:Parameter Name="password" Type="String" />
                        </InsertParameters>
                    </asp:ObjectDataSource>
                </fieldset>
            </td>
        </tr>
        <tr>
            <td>
                <fieldset>
                    <legend>New User</legend>
                    <table>
                        <tr>
                            <th></th>
                            <th>Username</th>
                            <th>Password</th>
                            <th>Email Address</th>
                            <th>Admin</th>
                        </tr>
                        <tr>
                            <td>
                                <asp:Button ID="addUserButton" runat="server" Text="Add" OnClick="addUserButton_OnClick" CssClass="myButton" />
                            </td>
                            <td>
                                <asp:TextBox ID="userNameTextBox" runat="server" ></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox ID="passwordTextBox" runat="server" TextMode="Password" ></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox ID="emailTextBox" runat="server" ></asp:TextBox>
                            </td>
                            <td>
                                <asp:CheckBox ID="adminCheckBox" runat="server" />
                            </td>
                        </tr>
                    </table>
                </fieldset>
            </td>
        </tr>
    </table>
</asp:Content>
